USE [RuiTaiWebsiteDB]
GO
/****** Object:  UserDefinedFunction [dbo].[fun_getWorkStartHour]    Script Date: 12/07/2011 21:40:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create FUNCTION [dbo].[fun_getWorkStartHour] (
)
RETURNS numeric(18,0)
BEGIN
	DECLARE @WorkStartHour numeric(18,0)
	DECLARE @Count numeric(18,0)
	SELECT @Count=Count(*) from DB_WorkingTimeInfo
	if(@Count>0)
	SELECT @WorkStartHour = CAST(LEFT(WorkingStartTime, 2) AS int)
	FROM  DB_WorkingTimeInfo
	else
	Set @WorkStartHour=9
	RETURN @WorkStartHour
END


USE [RuiTaiWebsiteDB]
GO
/****** Object:  UserDefinedFunction [dbo].[fun_getWorkEndHour]    Script Date: 12/07/2011 21:40:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create FUNCTION [dbo].[fun_getWorkEndHour] (
)
RETURNS numeric(18,0)
BEGIN
	DECLARE @WorkEndHour numeric(18,0)
	DECLARE @Count numeric(18,0)
	SELECT @Count=Count(*) from DB_WorkingTimeInfo
	if(@Count>0)
	SELECT @WorkEndHour = CAST(LEFT(WorkingEndTime, 2) AS int)
	FROM  DB_WorkingTimeInfo
	else
	Set @WorkEndHour=18
	RETURN @WorkEndHour
END